package cn.demo.cm.service.impl;

import java.util.List;
import com.mybatisflex.core.paginate.Page;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.demo.cm.mapper.CmCategoryMapper;
import cn.demo.cm.domain.CmCategory;
import cn.demo.cm.service.ICmCategoryService;

/**
 * 栏目管理Service业务层处理
 *
 * @author xtjun
 * @date 2024-06-06
 */
@Service
public class CmCategoryServiceImpl extends ServiceImpl<CmCategoryMapper, CmCategory> implements ICmCategoryService {
    @Resource
    private CmCategoryMapper cmCategoryMapper;
    /**
     * 查询栏目管理
     *
     * @param id 栏目管理主键
     * @return 栏目管理
     */
    @Override
    public CmCategory selectCmCategoryById(String id) {
        return cmCategoryMapper.selectOneById(id);
    }

    /**
     * 查询栏目管理列表
     *
     * @param cmCategory 栏目管理
     * @return 栏目管理
     */
    @Override
    public Page<CmCategory> selectCmCategoryPage(CmCategory cmCategory, PageQuery pageQuery) {
        return cmCategoryMapper.paginate(pageQuery.build(), QueryWrapper.create(cmCategory,CmCategory.operators));
    }
    @Override
    public List<CmCategory> selectCmCategoryList(CmCategory cmCategory) {
        return cmCategoryMapper.selectListByQuery(QueryWrapper.create(cmCategory,CmCategory.operators));
    }

    /**
     * 新增栏目管理
     *
     * @param cmCategory 栏目管理
     * @return 结果
     */
    @Override
    public int insertCmCategory(CmCategory cmCategory) {
        return cmCategoryMapper.insert(cmCategory);
    }

    /**
     * 修改栏目管理
     *
     * @param cmCategory 栏目管理
     * @return 结果
     */
    @Override
    public int updateCmCategory(CmCategory cmCategory) {
        return cmCategoryMapper.update(cmCategory);
    }

    /**
     * 批量删除栏目管理
     *
     * @param ids 需要删除的栏目管理主键
     * @return 结果
     */
    @Override
    public int deleteCmCategoryByIds(List<String> ids) {
        return cmCategoryMapper.deleteBatchByIds(ids);
    }

    /**
     * 删除栏目管理信息
     *
     * @param id 栏目管理主键
     * @return 结果
     */
    @Override
    public int deleteCmCategoryById(String id) {
        return cmCategoryMapper.deleteById(id);
    }
}
